<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('审核事项')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-matterProjrect-edit" th:object="${lkMatterProject}">
            <input name="id" th:field="*{id}" type="hidden">
			<input name="projectId" th:field="*{projectId}" type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">项目名称：</label>
				<div class="col-sm-8">
					<span th:text="*{projectName}"></span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">事项名称：</label>
				<div class="col-sm-8">
				<span th:text="*{name}"></span>
				</div>
			</div>
            <div class="form-group">
				<label class="col-sm-3 control-label">审核状态：</label>
				<div class="col-sm-8">
				    <div class="radio-box" th:each="dict : ${@dict.getType('matterProject_status')}">
						<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">审核描述：</label>
				<div class="col-sm-8">
					<textarea name="statusRemark" id="statusRemark" class="form-control"></textarea>
				</div>
			</div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "linkong/matterProject";
        $("#form-matterProjrect-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
				edit();
            }
        }

        function edit() {
			var id = $("input[name='id']").val();
			var projectId = $("input[name='projectId']").val();
			var status = $('input:radio:checked').val();
			var statusDate = null;
			if (status == '1'){
				statusDate = getDate();
			}
			var statusRemark = $('#statusRemark').val();
			$.ajax({
				cache : true,
				type : "POST",
				url : prefix + "/edit",
				data : {
					"id":id,
					"projectId": projectId,
					"status": status,
					"statusDate": statusDate,
					"statusRemark": statusRemark
				},
				async : false,
				error : function(request) {
					$.modal.alertError("系统错误");
				},
				success : function(data) {
					$.operate.successCallback(data);
				}
			});
		}

		function getDate() {
			// 获取当前日期
			var date = new Date();

			// 获取当前月份
			var nowMonth = date.getMonth() + 1;

			// 获取当前是几号
			var strDate = date.getDate();

			// 添加分隔符“-”
			var seperator = "-";

			// 对月份进行处理，1-9月在前面添加一个“0”
			if (nowMonth >= 1 && nowMonth <= 9) {
				nowMonth = "0" + nowMonth;
			}

			// 对月份进行处理，1-9号在前面添加一个“0”
			if (strDate >= 0 && strDate <= 9) {
				strDate = "0" + strDate;
			}

			// 最后拼接字符串，得到一个格式为(yyyy-MM-dd)的日期
			var nowDate = date.getFullYear() + seperator + nowMonth + seperator + strDate;
			return nowDate;
		}
    </script>
</body>
</html>